import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Atras here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Atras extends Actor
{
    /**
     * Act - do whatever the Atras wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        interseccionBoton();
        clickBoton();
    }    
    
    /**
     * Metodo para checar si se dio click dentro del boton atras.
     */
    
    public void interseccionBoton()
    {
        if(Greenfoot.mouseMoved(null))
        {
            MouseInfo raton = Greenfoot.getMouseInfo();
            if(raton.getActor() == this)
            {
                World mundo= (World)getWorld();
                GreenfootImage i;
                setImage("Atras1.png");
                i=super.getImage();
                i.scale((i.getWidth())+10, (i.getHeight())+10);
                super.setImage(i);
            }
            else
                setImage("Atras.png");
        }
    }
    
    /**
     * Metodo para ver si se presiono el click.
     */
    
     public void clickBoton()
    { 
         if( Greenfoot.mouseClicked( null ))
        {
            MouseInfo raton = Greenfoot.getMouseInfo();
            Actor personaje=raton.getActor();
            if(personaje instanceof Atras)
            {
                World mundo=(World)getWorld();
                mundo.removeObjects(mundo.getObjects(null));
                 ((Mundo)mundo).menu();
                 ((Mundo)mundo).cambiaDano(100);
                 ((Mundo)mundo).cambiaScore(0);
                 ((Mundo)mundo).cambiaNumbalas(5);
                  ((Mundo)mundo).cambianum(500);
                    ((Mundo)mundo).cambiaNivel(0);
                //mundo.setBackground("portadaXida.png");
                 
            }
        }
    }
}
